package ai.people.netmon.framework.domain.facebook.monitor.request;

import ai.people.netmon.framework.domain.facebook.view.entity.FacebookAccountView;
import ai.people.netmon.framework.model.request.PageKeyWordsRequest;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * <p>
 *
 * </p>
 *
 * @author zhenglin
 * @since 2022/3/8
 */
@Data
public class MonitorUsersRequest extends PageKeyWordsRequest {

    public LambdaQueryWrapper<FacebookAccountView> createQueryWrapper(){
        LambdaQueryWrapper<FacebookAccountView> queryWrapper = Wrappers.lambdaQuery();
        String searchKeywords = this.getSearchKeywords();
        if (StringUtils.isNotBlank(searchKeywords)){
            queryWrapper.like(FacebookAccountView::getAccountId,searchKeywords).or().like(FacebookAccountView::getAccountName,searchKeywords)
                    .or().like(FacebookAccountView::getAccountLink,searchKeywords);
        }
        return queryWrapper;
    }
}
